// Interface of a widget that can contain flyweights
// Copyright 2006 (C) Ralph Thomas

#ifndef MISSION_VIEW_GTK_FLYWEIGHT_PARENT_H
#define MISSION_VIEW_GTK_FLYWEIGHT_PARENT_H

#include <gtk/gtk.h>
#include <string>
#include "binder.hpp"

namespace view {

	struct flyweight_parent {
		virtual ~flyweight_parent();
		//
		/// Adopt the given cell renderer and ensure that it gets
		/// drawn at the right time and handed activate and edit
		/// events when appropriate.
		///
		/// \param	r	the cell renderer to adopt.
		//
		virtual void adopt_renderer(GtkCellRenderer* r) = 0;
		//
		/// Set the position of this renderer. The xpad and ypad
		/// properties of the renderer cannot be used for this
		/// purpose, unfortunately.
		///
		/// \param	r	the renderer to set the position of.
		/// \param	x	the x-coordinate of the renderer.
		/// \param	y	the y-coordinate of the renderer.
		//
		virtual void position_renderer(GtkCellRenderer* r, int w, int h, int x, int y) = 0;
		/// Adopt the given datapump. The datapump should supply
		/// the specified property (a GObject property) of the
		/// renderer.
		///
		/// \param	target		the renderer that the datapump
		///				supplies.
		/// \param	property	the property to set.
		/// \param	datapump	the datapump to adopt.
		//
		virtual void adopt_datapump(GtkCellRenderer* target, const std::string& property, const adobe::value_t& datapump) = 0;
		//
		/// Set a value into a datapump that's owned by this
		/// parent.
		///
		/// \param	value		the value to set.
		//
		virtual void set(const adobe::value_t& value) = 0;
		//
		/// Put the index of the thing that's being drawn into
		/// the renderer so that it can cause this area to be
		/// invalidated later (the icon renderer does this when
		/// it encounters an image that it doesn't have a
		/// thumbnail for).
		///
		/// \param	target		the renderer to inform of the index.
		/// \param	property	the property to set to the index.
		//
		virtual void subscribe_index(GtkCellRenderer* target, const std::string& property) = 0;
		//
		/// Return the widget that this parent uses. It's needed
		/// for doing measurement of the cell renderers (they
		/// have to lookup the font, etc, from the given widget).
		///
		/// \return	our gtk widget.
		//
		virtual GtkWidget* get_widget() const = 0;
		//
		/// Redraw the currently visible set of items. This is
		/// typically called when some data has changed.
		///
		/// \param	index	the index of the changed item.
		//
		virtual void redraw(unsigned int index) = 0;
		//
		/// Redraw everything that's visible!
		//
		virtual void redraw_all() = 0;
	};

};

#endif

